﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_AddNewSpecialRecharge : System.Web.UI.Page
{
    private ServiceBlo _blo = new ServiceBlo();
    private ServiceDetail _serviceDetail;
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void txtDurationDate_TextChanged(object sender, EventArgs e)
    {
        if (!txtDenomination.Text.Equals("")&&!txtDurationDate.Text.Equals("")&&!txtDiscount.Text.Equals(""))
        {
            float total = float.Parse(txtDenomination.Text.ToString()) * int.Parse(txtDurationDate.Text.ToString()) 
                            * (100 - int.Parse(txtDiscount.Text.ToString())) / 100;
            txtTotal.Text = total.ToString();
        }
         if (txtDurationDate.Text.Equals(""))
        {
            txtDurationDate.Focus();
        }
        else if (txtDenomination.Text.Equals(""))
        {
            txtDenomination.Focus();   
        }
        else if (txtDiscount.Text.Equals(""))
        {
            txtDiscount.Focus();
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        bool status = false;
        if (rbtnActive.Checked)
        {
            status = true;
        }
        _serviceDetail = new ServiceDetail(2, txtPackage.Text, int.Parse(txtDurationDate.Text.ToString()), 0, txtDescription.Text,
                int.Parse(txtDiscount.Text.ToString()), float.Parse(txtDenomination.Text.ToString()), float.Parse(txtTotal.Text.ToString()),status);
        _blo.InsertServiceDetail(_serviceDetail);
        Response.Redirect("SpecialRechargeManager.aspx");
    }
}